home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / intro.dxr / 00035_DEMO - midiTest handler.ls < prev    next >
Encoding:
Text File  |  1996-02-15  |  2.1 KB  |  66 lines

  1. on midiTest
  2.   openXLib("midixobj")
  3.   addLine("MIDI XObject opened")
  4.   set windowsMIDIXObj to midixobj(mnew)
  5.   if not objectp(windowsMIDIXObj) then
  6.     addLine("Unable to create XObject instance - aborting")
  7.     abort()
  8.   end if
  9.   set devNums to value(windowsMIDIXObj(mGetDevIDs))
  10.   set outDevNums to getAt(devNums, 2)
  11.   set numOutDevs to count(outDevNums)
  12.   if numOutDevs > 0 then
  13.     repeat with device = 1 to numOutDevs
  14.       set outDevID to getAt(outDevNums, device)
  15.       set outDevName to windowsMIDIXObj(mGetDevName, "OUT", outDevID)
  16.       if windowsMIDIXObj(mOpenOut, outDevID, 1000) then
  17.         addLine("^^^ Unable to open this device")
  18.         next repeat
  19.       end if
  20.       addLine("Middle C Note On - Channel")
  21.       repeat with loop = 0 to 15
  22.         windowsMIDIXObj(mWrite, string(144 + loop) && "60 127")
  23.         addStr(" " & loop)
  24.       end repeat
  25.       if windowsMIDIXObj(mCloseOut) then
  26.         addLine("^^^ Problems encountered closing this device down")
  27.       end if
  28.     end repeat
  29.   else
  30.     addLine("No output devices available")
  31.   end if
  32.   set inDevNums to getAt(devNums, 1)
  33.   addLine("Input device numbers:" && inDevNums)
  34.   set numInDevs to count(inDevNums)
  35.   if numInDevs > 0 then
  36.     repeat with device = 1 to numInDevs
  37.       set inDevID to getAt(inDevNums, device)
  38.       set inDevName to windowsMIDIXObj(mGetDevName, "IN", inDevID)
  39.       addLine("Running test for INPUT device '" & inDevName & "' (ID =" && inDevID & ")")
  40.       if windowsMIDIXObj(mOpenIn, inDevID, 10000) then
  41.         addLine("^^^ Unable to open this device")
  42.         next repeat
  43.       end if
  44.       addLine("Incoming data:")
  45.       startTimer()
  46.       repeat while the timer < 120
  47.         set inData to windowsMIDIXObj(mRead)
  48.         if inData <> EMPTY then
  49.           addLine(inData)
  50.           startTimer()
  51.         end if
  52.       end repeat
  53.       if windowsMIDIXObj(mCloseIn) then
  54.         addLine("^^^ Problems encountered closing this device down")
  55.       end if
  56.     end repeat
  57.   else
  58.     addLine("No input devices available")
  59.   end if
  60.   windowsMIDIXObj(mdispose)
  61.   addLine("Disposed of XObject instance")
  62.   closeXLib("midixobj")
  63.   addLine("MIDI XObject closed")
  64.   addLine("* TEST COMPLETE *")
  65. end
  66.